<!DOCTYPE html>
<html>
    <head>
        <title>消息</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="Content-Language" content="zh-CN" />
        <meta http-equiv="Content-Script-Type" content="text/javascript" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
        <meta name="format-detection" content="telephone=no"/>
		<link rel="stylesheet" href="css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" href="css/index.css"/>
		<style>
			.title_top{text-align: center;}
			.news{margin-top: 50px;}
			.news_news .news_right{float:right;margin-top:-3%;}
			.nodata{margin:0 auto;text-align:center;padding-top:50%;}
			.nodata img{width:50%;height:50%;}
		</style>
    </head>
	<body class="body_1">
		<div class="col-xs-12 title_top">
			消息
		</div>
		<div class="col-xs-12 news lists">
		</div>
		<div class="col-xs-12 bot navigates">
			<div class="col-xs-3 nav" data-model="home" >
				<div class="myReport active">
					<div class="icon_1 icon" ></div>
					<div class="wz">统计</div>
				</div>
			</div>
			<div class="col-xs-3 nav" data-model="project" >
				<div class="myReport">
					<div class="icon_2 icon" ></div>
					<div class="wz">项目</div>
				</div>
			</div>
			<div class="col-xs-3 nav" data-model="news" >
				<div class="myReport active">
					<div class="icon_3 icon active" ></div>
					<div class="wz active">消息</div>
				</div>
			</div>
			<div class="col-xs-3 nav" data-model="member" >
				<div class="myReport">
					<div class="icon_4 icon" ></div>
					<div class="wz">我的</div>
				</div>
			</div>
		</div>
	</body>
</html>
<script src="js/mui.min.js"></script>
<script src="js/project.config.js"></script>
<script src="js/jquery.min.js"></script>
<script> 
	mui.plusReady(function(){
		var token = get_token();
		var data = {};
		data.api = 'get-user-messages';
		data.token = token;
		mui.ajax(project_cofnig.service_url, {
			async: true,
			dataType: 'json',
			data: data,
			success: function (ref) {
				if(ref.code == 0){
					if(ref.data.recCount < 0){
						$(".lists").html("<div class='nodata'><img src='images/nodata.png'></div>");
						return false;
					}
					var _html = '';
					mui.each(ref.data.records,function(i,v){
						_html += '<div class="col-xs-12 news_news" data-id="'+v.id+'">';
						_html += '<div class="col-xs-3">';
						_html += '<img class="news_img" src="images/message.png" style="width:70%;" />';
						_html += '</div>';
						_html += '<div class="col-xs-6" style="margin-left:-6%;">';
						_html += '<p class="news_p_1">'+v.senderName+'<span>'+v.receiverName+'</span></p>';
						_html += '<p class="news_p_2">'+v.title+'</p>';
						_html += '</div>';
						_html += '<div class="col-xs-6 news_right">'+v.sendDate+'</div>';
						_html += '</div>';
					});
					$(".lists").html(_html);
				}
			}
		});
		mui(".lists").on("tap",".news_news",function(){
			redirect('new_detail.html',{
				messageId:$(this).data('id'),
			});
		});
		mui(".navigates").on('tap','.nav',function(){
				var model = $(this).data('model');
				var url = '';
				if(model != 'news' ){
					switch(model){
						case 'project':
							url = 'lists.html';
							break;
						case 'news':
							url = 'news.html';
							break;
						case 'member':
							url = 'userinfo.html';
							break;
						default:
							url = 'home.html';
					}
					redirect(url);
				}
				return false;
		});
	});
</script>